﻿<Window x:Class="CodeSHARPer.View.Dialogs.CodeReferencesView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:CodeCompletion="clr-namespace:ICSharpCode.CodeCompletion;assembly=ICSharpCode.CodeCompletion"
        xmlns:avalonDock="http://avalondock.codeplex.com"
        Height="600" Width="600"
        Title="Code References" Icon="..\..\Themes\Images\App\Ico\app.tools.ico" ShowInTaskbar="False"
        WindowStartupLocation="CenterOwner" WindowStyle="ToolWindow">

    <Window.Resources>
        <avalonDock:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter"/>
    </Window.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <TabControl HorizontalAlignment="Stretch" Margin="3" VerticalAlignment="Stretch" Grid.Row="0">
            <TabItem Header="Namespaces">

                <GroupBox Header="Namespace per line" Grid.Column="0" Grid.RowSpan="3" Margin="3">
                    <CodeCompletion:CodeTextEditor
                            x:Name="textEditor" Grid.Row="0" Margin="2"
                            Document="{Binding Document, UpdateSourceTrigger=PropertyChanged}"
                            CodeCompletion="{Binding CodeCompletion}"
                            FullName="{Binding FilePath}"
                            FontFamily="Consolas"
                            FontSize="14"
                            ShowLineNumbers="True" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
                    </CodeCompletion:CodeTextEditor>
                </GroupBox>

            </TabItem>

            <TabItem Header="References">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>

                    <ListView Grid.Row="0" ItemsSource="{Binding UsedReferences}" BorderThickness="0">
                        <ListView.ContextMenu>
                            <ContextMenu>
                                <MenuItem Header="Add..." Command="{Binding AddFrameworkReferenceCommand}" />
                                <MenuItem Header="Remove" Command="{Binding RemoveReferenceCommand}"/>
                                <MenuItem Header="Browse..." Command="{Binding BrowseReferenceCommand}"/>
                                <MenuItem Header="NuGet..." Command="{Binding NuGetReferencesCommand}"/>
                            </ContextMenu>
                        </ListView.ContextMenu>
                        <ListView.View>
                            <GridView>
                                <GridView.ColumnHeaderContainerStyle>
                                    <Style>
                                        <Setter Property="FrameworkElement.Visibility" Value="Collapsed"/>
                                    </Style>
                                </GridView.ColumnHeaderContainerStyle>
                                <GridViewColumn Header="IsSeleted">
                                    <GridViewColumn.CellTemplate>
                                        <DataTemplate>
                                            <CheckBox IsChecked="{Binding IsSeleted}" />
                                        </DataTemplate>
                                    </GridViewColumn.CellTemplate>
                                </GridViewColumn>
                                <GridViewColumn Header="Name">
                                    <GridViewColumn.CellTemplate>
                                        <DataTemplate>
                                            <StackPanel Orientation="Vertical">
                                                <TextBlock Text="{Binding Name}" TextAlignment="Left"/>
                                                <TextBlock Text="{Binding Location}" TextAlignment="Left"/>

                                                <TextBlock Text="{Binding Error}"
                                                           Visibility="{Binding HasError, Converter={StaticResource BoolToVisibilityConverter}}"
                                                           TextAlignment="Left" Foreground="Red"/>
                                            </StackPanel>
                                        </DataTemplate>
                                    </GridViewColumn.CellTemplate>
                                </GridViewColumn>
                            </GridView>
                        </ListView.View>
                    </ListView>

                    <StackPanel Grid.Row="1" Orientation="Horizontal">
                        <Button Content="Add..." Command="{Binding AddFrameworkReferenceCommand}" Margin="5" Padding="3"/>
                        <Button Content="Remove" Command="{Binding RemoveReferenceCommand}" Margin="5" Padding="3"/>
                        <Button Content="Browse..." Command="{Binding BrowseReferenceCommand}" Margin="5" Padding="3" />
                        <Button Content="Add NuGet..." Command="{Binding NuGetReferencesCommand}" Margin="5" Padding="3" Width="75" />
                    </StackPanel>
                </Grid>
            </TabItem>
        </TabControl>

        <StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right">
            <Button Content="OK" Width="75" IsDefault="True" Margin="5" Padding="3"
                    Command="{Binding CloseActivePopUpCommand}" CommandParameter="True" />
            <Button Content="Cancel" Width="75" IsCancel="True" Margin="5" Padding="3"/>
        </StackPanel>

    </Grid>
</Window>
